#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableBagConfigDao:DaoBase<TableBagConfig>
    {
        public override string GetFileName()
        {
            return "TableBagConfig.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableBagConfig>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddPrimaryIndex(TableBagConfig model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.configId)) UnityEngine.Debug.LogError("数据表id重复:TableBagConfig->id: " + model.configId);
            #endif
            cachePrimaryInt[model.configId] = model;
        }
        protected override TableBagConfig ParseRowData(string[] rowData)
        {
            TableBagConfig data = new TableBagConfig();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.configId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.bagType = int.Parse(rowData[1]);
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.cellTotalNumber = int.Parse(rowData[2]);
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.freeCellNumber = int.Parse(rowData[3]);
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.rowNumber = int.Parse(rowData[4]);
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.rowOffer = rowData[5];
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.pageMax = int.Parse(rowData[6]);
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.isUnlimit = int.Parse(rowData[7]);
            }
            if (!string.IsNullOrEmpty(rowData[8]))
            {
                data.defaultOpen = int.Parse(rowData[8]);
            }
            return data;
        }
    }
}
